/**
 * 
 */
package org.wolf.core.schema;

import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.queryParser.QueryUtil;
import org.apache.lucene.search.Query;

/**
 * @author 何小锋
 * 
 */
public class TextField extends FieldType {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public boolean isTokenized() {
		return true;
	}

	@Override
	public void setTokenized(boolean tokenized) {
	}

	@Override
	public void setOmitTf(boolean omitTf) {
	}

	@Override
	public Query getFieldQuery(QueryParser parser, DocField field, String value) {
		if (value == null || value.isEmpty())
			return super.getFieldQuery(parser, field, value);

		try {
			return QueryUtil.getFieldQuery(parser, field.getName(), value,
					false);
		} catch (ParseException e) {
		}
		return null;
	}

}
